package com.resume.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * Map工具类
 *
 * @author 梁云亮
 */
public class MapUtil {
    public static <K, V> MapBuilder<K, V> builder() {
        return new MapBuilder<>(new HashMap<>());
    }

    public static class MapBuilder<K, V> {
        private final Map<K, V> map;

        public MapBuilder(Map<K, V> map) {
            this.map = map;
        }

        public MapBuilder<K, V> put(K k, V v) {
            map.put(k, v);
            return this;
        }

        public Map<K, V> build() {
            return map;
        }
    }

    public static void main(String[] args) {
        Map<Object, Object> map = MapUtil.builder().put("a", "aaaa").put("b", 1111).build();
        map.forEach((k, v) -> System.out.println(k + " : " + v));
    }


}